#include <math.h>
#include "mathutils.h"

static unsigned int randSeed = 22222;  // Change this for different random sequences. 

void SetSeed(unsigned int seed) {
	randSeed = seed * 382792592;
}

unsigned int GenerateRandomNumber() {
	randSeed = (randSeed * 196314165) + 907633515;
	randSeed ^= _rotl(randSeed, 13);
	return randSeed;
}

// MinBLEP Generation Code
// By Daniel Werner
// This Code Is Public Domain

#include <math.h>

/*
void add_minstep( double* out, int count, int oversample )
{
    double maxh = 201; // keeps adjacent transitions from interfering
    double h;
    for ( h = 1.0; h <= maxh; h += 2.0 )
    {
        double rate = 3.1415926535897932 * h / (maxh * oversample);
        double x = (maxh - h) / (maxh - 1.0); // goes from 1.0 to 0.0
        double curve = pow( x, 0.37 ) - 1.0;
        double phase = curve * 13.2 - oversample * rate;
        int i;
        for ( i = 0; i < count; i++ )
            out [i] += sin( i * rate + phase ) / h;
    }
}
*/


/* 
Lorenz attractor

#include "stdio.h"
#include "stdlib.h"
#include "math.h"

#define N 10000

int main(int argc,char **argv)
{
   int i=0;
   double x0,y0,z0,x1,y1,z1;
   double h = 0.01;
   double a = 10.0;
   double b = 28.0;
   double c = 8.0 / 3.0;

   x0 = 0.1;
   y0 = 0;
   z0 = 0;
   for (i=0;i<N;i++) {
      x1 = x0 + h * a * (y0 - x0);
      y1 = y0 + h * (x0 * (b - z0) - y0);
      z1 = z0 + h * (x0 * y0 - c * z0);
      x0 = x1;
      y0 = y1;
      z0 = z1;
      if (i > 100)
         printf("%d %g %g %g\n",i,x0,y0,z0);
   }
}

*/